<%@page contentType="text/html; charset=utf-8"%>

<div class="form-container">
	<form id="form">
		<table class="tableform">
			<tr>
				<th class="td100">原密码：</th>
				<td><input name="oldPassword" class="easyui-validatebox" type="password" data-options="prompt: '原密码', required:true" /></td>
			</tr>
			<tr>
				<th>新密码：</th>
				<td><input id="password" name="password" class="easyui-validatebox" type="password" data-options="required:true, prompt: '新密码'" /></td>
			</tr>
			<tr>
				<th>确认密码：</th>
				<td><input validType="equals[$('#password').val()]" invalidMessage="两次输入密码不匹配" class="easyui-validatebox" type="password" data-options="required:true, prompt: '确认密码'" /></td>
			</tr>
			<tr style="display:none">
				<td>
					<input type="text" name="id" value="${currentUser.user.id}">
				</td>
			</tr>
		</table>
	</form>
</div>

<script>
	var form_url = "${ctx}/admin/sys/user/changePassword" ;
	
	//提交表单数据
	var submitNow = function($d) {
		var data = $("#form").form("getData") ;
		$.post(form_url, data, function(result) {
			if (result.status) {
				$.easyui.loaded();
				$d.dialog("close");
				$.messager.alert("提示", result.message, "info");
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.message, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};

	//验证表单
	var submitForm = function($d) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d) ;
		}
	};
</script>

